home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue54 / Persist / FEditEAddress.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-01-21  |  2.4 KB  |  85 lines

  1. {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2.   (c) TechInsite Pty. Ltd.
  3.   PO Box 429, Abbotsford, Melbourne. 3067 Australia
  4.   Phone: +61 3 9419 6456
  5.   Fax:   +61 3 9419 1682
  6.   Web:   www.techinsite.com.au
  7.   EMail: peter_hinrichsen@techinsite.com.au
  8.  
  9.   Created: Jan 2000
  10.  
  11.   Notes: Popup dialog to edit an EAddress
  12.  
  13. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
  14. unit FEditEAddress;
  15.  
  16. interface
  17.  
  18. uses
  19.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  20.   StdCtrls, ExtCtrls, tiButtonPanel, Adrs_BOM ;
  21.  
  22. type
  23.   TFormEditEAddress = class(TForm)
  24.     cbAddressType: TComboBox;
  25.     eAddress: TEdit;
  26.     tiButtonPanel1: TtiButtonPanel;
  27.     Label1: TLabel;
  28.     Label2: TLabel;
  29.     procedure tiButtonPanel1Btn1Click(Sender: TObject);
  30.     procedure tiButtonPanel1Btn2Click(Sender: TObject);
  31.   private
  32.     FData: TEAddress;
  33.     procedure SetData(const Value: TEAddress);
  34.     { Private declarations }
  35.   public
  36.     Property Data : TEAddress read FData write SetData ;
  37.   end;
  38.  
  39. implementation
  40.  
  41. {$R *.DFM}
  42.  
  43. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  44. // *
  45. // * TFormEditEAddress
  46. // *
  47. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  48. // Set the form's data property and assign data to the GUI
  49. procedure TFormEditEAddress.SetData(const Value: TEAddress);
  50. begin
  51.   FData := Value;
  52.   cbAddressType.ItemIndex := cbAddressType.Items.IndexOf( FData.EAdrsType ) ;
  53.   eAddress.Text := FData.Text ;
  54. end;
  55.  
  56. // OK button's OnClick event
  57. //------------------------------------------------------------------------------
  58. procedure TFormEditEAddress.tiButtonPanel1Btn1Click(Sender: TObject);
  59. begin
  60.   if cbAddressType.ItemIndex = -1 then begin
  61.     cbAddressType.SetFocus ;
  62.     raise exception.Create( 'Please enter an EAddress type.' ) ;
  63.   end ;
  64.  
  65.   if eAddress.Text = '' then begin
  66.     eAddress.SetFocus ;
  67.     raise exception.Create( 'Please enter a phone number / EAddress.' ) ;
  68.   end ;
  69.  
  70.   FData.EAdrsType := cbAddressType.Items[cbAddressType.ItemIndex] ;
  71.   FData.Text := eAddress.Text ;
  72.  
  73.   ModalResult := mrOK ;
  74.  
  75. end;
  76.  
  77. // Cancel button's OnClick event
  78. //------------------------------------------------------------------------------
  79. procedure TFormEditEAddress.tiButtonPanel1Btn2Click(Sender: TObject);
  80. begin
  81.   ModalResult := mrCancel ;
  82. end;
  83.  
  84. end.
  85.